// pages/shopping/order/order.js
const app = getApp()
const connector = require('../../../utils/connector.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bar_Height: wx.getSystemInfoSync().statusBarHeight + 45,
    list:[],
    conUser:"",
  },
  details(e){
    let that = this
    console.log(e)
    let headline = that.data.list
    let arr=[]
    for(let i = 0;i < headline.length;i++){
      if(headline[i].id == e.currentTarget.dataset.id){
        arr.push(headline[i]) 
      }
    }
    wx.setStorageSync('headlineBuy', arr)
    // let arr = []
    // var shopping = {
    //   id: headline.id,
    //   // category_id: headline.category_id,
    //   main_img_url: headline.main_img_url,
    //   name: headline.name,
    //   price: headline.price,
    //   send_type: headline.send_type
    // }
    // console.log(headline)
    // // arr.push(headline)
    // arr.push(shopping)
    // wx.setStorageSync('headlineBuy', arr)
    // wx.setStorageSync('buy_num', 2)
    wx.navigateTo({
      url: '/pages/shopping/order/details',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    sundryList(this)
    this.setData({
      conUser:app.conUsers
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },
  /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {
    var that = this
    wx.hideNavigationBarLoading() //完成停止加载
    wx.stopPullDownRefresh() //停止下拉刷新

  },
})
//获取课程列表  
function sundryList(that) {
  connector.getFunc(connector.connector().sundryList, "", "get", app.tokens, function (res) {
    console.log(res)
    if (res.statusCode == 200) {
    console.log(res.data)
    that.setData({
      list:res.data.data
    })

      // WxParse.wxParse('article', 'html', res.data.result.content, that);
    } else {
      connector.showToasts(res.statusCode + ":" + res.errMsg)

    }
  }, function (res) {
    connector.showToasts("内部错误")
  })
}